package com.bank.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 客户信息实体类
 * 对应数据库表：user_info
 * 
 * @author 开发团队
 * @version 1.0.0
 * @since 2025-06-19
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("user_info")
public class UserInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 客户编号-主键
     */
    @TableId(value = "customer_id", type = IdType.AUTO)
    private Integer customerId;

    /**
     * 客户姓名
     */
    @TableField("customer_name")
    @NotBlank(message = "客户姓名不能为空")
    @Size(max = 50, message = "客户姓名长度不能超过50个字符")
    private String customerName;

    /**
     * 身份证号-18位唯一
     */
    @TableField("pid")
    @NotBlank(message = "身份证号不能为空")
    @Pattern(regexp = "^[0-9]{17}[0-9Xx]$", message = "身份证号格式不正确，应为18位数字或17位数字+1位数字/字母")
    private String pid;

    /**
     * 联系电话-11位数字
     */
    @TableField("telephone")
    @NotBlank(message = "联系电话不能为空")
    @Pattern(regexp = "^[0-9]{11}$", message = "联系电话格式不正确，应为11位数字")
    private String telephone;

    /**
     * 联系地址-可选
     */
    @TableField("address")
    @Size(max = 200, message = "联系地址长度不能超过200个字符")
    private String address;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 构造函数
     */
    public UserInfo() {
    }

    /**
     * 带参构造函数
     * 
     * @param customerName 客户姓名
     * @param pid 身份证号
     * @param telephone 联系电话
     * @param address 联系地址
     */
    public UserInfo(String customerName, String pid, String telephone, String address) {
        this.customerName = customerName;
        this.pid = pid;
        this.telephone = telephone;
        this.address = address;
    }

    /**
     * 重写toString方法
     */
    @Override
    public String toString() {
        return "UserInfo{" +
                "customerId=" + customerId +
                ", customerName='" + customerName + '\'' +
                ", pid='" + pid + '\'' +
                ", telephone='" + telephone + '\'' +
                ", address='" + address + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}
